package com.ljx.funchat.user.domain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@AllArgsConstructor
@Getter
public enum RoomMemberRoleEnum {

    MEMBER(3, "普通成员"),
    MANAGER(2, "管理员"),
    GROUP_LEADER(1, "群主");


    private Integer role;
    private String desc;

    private static Map<Integer, RoomMemberRoleEnum> cache;

    static {
        cache = Arrays.stream(RoomMemberRoleEnum.values()).collect(Collectors.toMap(RoomMemberRoleEnum::getRole, Function.identity()));
    }

    public static RoomMemberRoleEnum of(Integer role) {
        return cache.get(role);
    }
}
